<?php

/* 
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
require_once ('../db_conn.php');
$sql="SELECT * FROM tb_ltcp1";
$a8s=$db->query($sql); //执行语句  $rs是一个结果集
$ab8s=$a8s->fetch_all(MYSQLI_BOTH);

$rec=isset($_GET['rec'])?$_GET['rec']:"";
date_default_timezone_set('prc');
if ($rec=='insert')
{
    $name=$_POST['name'];
    $typeid=$_POST['cat_id'];
    $price=$_POST['price'];
  
    $sql="insert into tb_ltcp(typeid,name,price,sj) values('$typeid','$name','$price','$sj')";
    
    
    $rs=$db->query($sql);
        if ($rs==FALSE)
    {
        echo "<script language='javascript' type='text/javascript'>";
        echo "alert('添加失败！');";
        echo "window.location.href='addproduct_html.php'";
        echo "</script>";
    }
    else
    {
        echo "<script language='javascript' type='text/javascript'>";
        echo "alert('添加成功！');";
        echo "window.location.href='product.php'";
        echo "</script>";  
    }

}
require ('addproduct_html.php');

$a8s->free();

$db->close();